<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hz.util.*"%>
<%@page import="com.hz.model.Service" %>
<%@page import="com.hz.model.User" %>
<%@page import="com.hz.control.UserControl" %>
<%@page import="com.hz.control.ActivityControl"%>
<%@page import="com.hz.model.Activity"%>
<%@page import="com.hz.control.ServiceControl"%>
 <%
      request.setCharacterEncoding("UTF-8");
      boolean isSuccess = false;
      Collection<Service> servelist = new ArrayList<Service>();
      if((Collection)session.getAttribute("servelist")!=null){
      servelist = (Collection)session.getAttribute("servelist");
      }
      if(request.getParameter("id")!=null&&!request.getParameter("id").equals("")&&request.getParameter("behavior")!=null&&!request.getParameter("behavior").equals("")&&request.getParameter("activity")!=null&&!request.getParameter("activity").equals("")&&request.getParameter("service")!=null&&!request.getParameter("service").equals("")&&request.getParameter("duty")!=null&&!request.getParameter("duty").equals(""))
      {
    	  Service s = new Service();
	      int uid =Integer.parseInt(request.getParameter("id"));
	      int behavior =Integer.parseInt(request.getParameter("behavior"));
	      int actid =Integer.parseInt(request.getParameter("activity"));
	      float service =Float.valueOf(request.getParameter("service")).floatValue();
	      String duty = new String(request.getParameter("duty").getBytes("iso-8859-1"),"UTF-8");
	  
	    System.out.print(uid+"AAAAAAA"+duty+"BBBBB"+service);
	  
	     session.setAttribute("addactivity",actid);
	     session.setAttribute("addservice",service);
	  //System.out.print(stuid);
	    if(ServiceControl.getHours(actid,uid)==0){//单个活动无法添加两次

	     s.setUserid(uid);
	     s.setBehavior(behavior);
	     s.setActId(actid);
	     s.setServicesHours(service);
	     s.setDuty(duty);
	     servelist.add(s);
	     isSuccess = true;
	}
	   }
	  String returnJson = "{\"status\":\"" + (isSuccess ?  1 : 0) + "\"}";
	  session.setAttribute("servelist",servelist);
	  //System.out.print(returnJson);
	  
  %>
 <%=returnJson %>